package io.bdmc.modules.bss.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.bdmc.common.annotation.FieldMeta;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 设备测试 实体
 * </p>
 *
 * @author ping
 * @since 2020-06-30
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
// "DeviceMeasure对象", description = "设备测试")
public class DeviceMeasure extends Model<DeviceMeasure> implements Cloneable {

    private static final long serialVersionUID = 1L;

    // "自增id")
    @TableId(value = "measure_id", type = IdType.AUTO)
    private Integer measureId;

    // "设备id")
    @FieldMeta(name = "设备id", description = "设备id")
    private Integer deviceId;

    private String deviceSn;

    // "路由id")
    @FieldMeta(name = "路由id", description = "路由id")
    private Integer routeId;

    // "设备ip")
    @FieldMeta(name = "设备ip", description = "设备ip")
    private String deviceIp;

    // "部门id")
    private Integer deptId;

    // "自动测试任务编号")
    private String autoTaskNum;

    // "本次自动测试的次数")
    private Integer autoTaskCount;

    // "是否设定为基准值")
    @FieldMeta(name = "是否设定为基准值,1设置", description = "是否设定为基准值,1设置")
    private Boolean standard;

    // "测量端口")
    @FieldMeta(name = "测量端口", description = "测量端口")
    private Integer channel;

    // "测量模式(1：启动自动测试，2：停止自动测试，3：启动单次测试)")
    @FieldMeta(name = "测量模式(1：启动自动测试，2：停止自动测试，3：启动单次测试)", description = "测量模式(1：启动自动测试，2：停止自动测试，3：启动单次测试)")
    private Integer action;

    // "量程(km)")
    @FieldMeta(name = "量程(km)", description = "量程(km)")
    private Integer endPosition;

    // "脉宽(ns)")
    @FieldMeta(name = "脉宽(ns)", description = "脉宽(ns)")
    private Integer pulseWidth;

    // "测量状态，0：空闲；1：正在自动测试；2：正在单次测试；3：单次测试完成；4：测试失败；")
    private Integer measureStatus;

    // "测量开始时间")
    @FieldMeta(name = "测量开始时间", description = "测量开始时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime startTime;

    // "测量结束时间")
    @FieldMeta(name = "测量结束时间", description = "测量结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime endTime;

    // "测量耗时，单位分钟")
    @FieldMeta(name = "测量耗时，单位分钟", description = "测量耗时，单位分钟")
    private Integer duration;

    // "分辨率")
    @FieldMeta(name = "分辨率", description = "分辨率")
    private BigDecimal resolution;

    // "折射率")
    @FieldMeta(name = "折射率", description = "折射率")
    private BigDecimal refIndex;

    // "波长(nm)")
    @FieldMeta(name = "波长", description = "波长")
    private BigDecimal wavelength;

    // "平均化次数")
    @FieldMeta(name = "平均化次数", description = "平均化次数")
    private Integer averageNum;

    // "长度(km)")
    @FieldMeta(name = "长度(km)", description = "长度(km)")
    private BigDecimal length;

    // "衰耗(dB)")
    @FieldMeta(name = "衰耗(dB)", description = "衰耗(dB)")
    private BigDecimal padControl;

    // "衰耗系数")
    @FieldMeta(name = "衰耗系数", description = "衰耗系数")
    private BigDecimal padControlQuotiety;

    // "回损")
    @FieldMeta(name = "回损", description = "回损")
    private BigDecimal returnLoss;

    // "sor文件路径")
    private String sorPath;

    // "sor_json")
    private String sorJson;

    // "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;

    // "创建人")
    private String createBy;

    @TableField(exist = false)
    private String fibreCoreName;

    @TableField(exist = false)
    private String deviceName;

    @TableField(exist = false)
    private List<DeviceMeasureEvent> events;

    @Override
    public DeviceMeasure clone() {
        DeviceMeasure object = null;
        try {
            object = (DeviceMeasure) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return object;
    }

    @Override
    public Serializable pkVal() {
        return this.measureId;
    }

}
